﻿//    Copyright 2014 LuoZhihui
//    Licensed under the Apache License, Version 2.0 (the "License");
//    you may not use this file except in compliance with the License.
//    You may obtain a copy of the License at
//      http://www.apache.org/licenses/LICENSE-2.0
//    Unless required by applicable law or agreed to in writing, software
//    distributed under the License is distributed on an "AS IS" BASIS,
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//    See the License for the specific language governing permissions and
//    limitations under the License.

#region  导入名称空间

using FluentNHibernate.Mapping;
using LotteryEngine.Model;

#endregion

namespace LotteryEngine.Repository.NHibernate.Mapping
{
	/// <summary>
	///     奖项设置映射
	/// </summary>
	public class ConfigMap : ClassMap<Config>
	{
		public ConfigMap()
		{
			Table(@"LOTTERY_CONFIG");
			LazyLoad();
			Id(x => x.Id)
				.Column("ID")
				.CustomType("Int64")
				.Access.Property()
				.CustomSqlType("NUMBER")
				.Not.Nullable()
				.Precision(10)
				.GeneratedBy.Sequence("LOTTERY_CONFIG_SEQ");
			Map(x => x.IsByeItem)
				.Column("IS_BYE_ITEM")
				.CustomType("Boolean")
				.Access.Property()
				.Generated.Never()
				.CustomSqlType("NUMBER")
				.Not.Nullable()
				.Precision(1);
			Map(x => x.LotteryCount)
				.Column("LOTTERY_COUNT")
				.CustomType("Int64")
				.Access.Property()
				.Generated.Never()
				.CustomSqlType("NUMBER")
				.Not.Nullable()
				.Precision(10);
			Map(x => x.PrizeBlance)
				.Column("PRIZE_BLANCE")
				.CustomType("Int64")
				.Access.Property()
				.Generated.Never()
				.CustomSqlType("NUMBER")
				.Not.Nullable()
				.Precision(10);
			Map(x => x.StartDate)
				.Column("START_DATE")
				.CustomType("DateTime")
				.Access.Property()
				.Generated.Never()
				.CustomSqlType("DATE")
				.Not.Nullable();
			Map(x => x.EndDate)
				.Column("END_DATE")
				.CustomType("DateTime")
				.Access.Property()
				.Generated.Never()
				.CustomSqlType("DATE")
				.Not.Nullable();
			Map(x => x.OddsCoefficient)
				.Column("ODDS_COEFFICIENT")
				.CustomType("Double")
				.Access.Property()
				.Generated.Never()
				.CustomSqlType("NUMBER")
				.Not.Nullable()
				.Precision(10)
				.Scale(6);
			Map(x => x.Proportion)
				.Column("PROPORTION")
				.CustomType("Double")
				.Access.Property()
				.Generated.Never()
				.CustomSqlType("NUMBER")
				.Precision(10)
				.Scale(6);
			Map(x => x.Probability)
				.Column("PROBABILITY")
				.CustomType("Double")
				.Access.Property()
				.Generated.Never()
				.CustomSqlType("NUMBER")
				.Precision(10)
				.Scale(6);
			Map(x => x.IsActived)
				.Column("IS_ACTIVED")
				.CustomType("Boolean")
				.Access.Property()
				.Generated.Never()
				.CustomSqlType("NUMBER")
				.Not.Nullable()
				.Precision(1);
			References(x => x.Sweepstake)
				.Class<Sweepstake>()
				.Access.Property()
				.Cascade.None()
				.LazyLoad()
				.Columns("SWEEPSTAKE_ID");
			References(x => x.Prize)
				.Class<Prize>()
				.Access.Property()
				.Cascade.None()
				.LazyLoad()
				.Columns("PRIZE_ID");
		}
	}
}